package com.carl.zlds.controller.web;

import com.carl.zlds.tool.common.result.Result;
import com.carl.zlds.annotation.Login;
import com.carl.zlds.pojo.vo.GameVO;
import com.carl.zlds.service.IGameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author carl
 */
@Slf4j
@RestController(value = "web.gameController")
@RequestMapping("/web/game")
@Api(tags = {"客户端 - 游戏管理"})
public class GameController {

    private final IGameService gameService;

    @Autowired
    public GameController(IGameService gameService) {
        this.gameService = gameService;
    }

    @ApiOperation("游戏列表")
    @GetMapping(value = "/list")
    @Login(needToken = false)
    public Result<Map<String, Object>> list() {
        List<GameVO> result = gameService.getGameList();
        Map<String, Object> map = new HashMap<>(1);
        map.put("list", result);
        return Result.success(map);
    }
}
